package com.servlet;

import com.dao.StudenCla;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@WebServlet("/checktest")
public class CheckClass extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        checkCl(req, resp);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        checkCl(req, resp);
    }

    //查
    static void checkCl(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        StudenCla students = new StudenCla();
        List list = null;
        try {
            list = students.checkCl();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        System.out.println(list);
        req.setAttribute("users2", list);
        req.getRequestDispatcher("list2.jsp").forward(req, resp);
//        resp.sendRedirect("list2.jsp").forward();
    }
}
